package cn.snorlaxzjt.LBSserver.common;

public enum BusinessCode {
    SUCCESS(0,"成功"),
    FAIL(-1,"失败"),
    LOGIN_FAIL(301,"登陆失败，请检查邮箱和密码"),
    VALIDATE_FAILED(404, "参数检验失败"),
    UNAUTHORIZED(401, "暂未登录或token已经过期"),
    FORBIDDEN(403, "没有相关权限"),
    EMAIL_VALIDATE_FAILED(502,"请检查邮箱格式"),
    EMAIL_EXIST(503,"邮箱已存在"),
    EMAIL_CODE_ERROR(504,"邮箱验证码错误"),
    SYSTEM_ERROR(10001, "系统异常");
    ;


    private final Integer code;
    private final String msg;
    private BusinessCode(Integer code,String msg){
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public <T>Result<T> toResult(T t){
        return new Result<T>(this,t);
    }

    public <T>Result<T> toResult(){
        return new Result<T>(this,null);
    }
}
